<template>
<form class="form-language">
  <select class="form-control" v-model="language" @change.prevent="onChange">
    <option v-for="option in lanOptions" :value="option.value">{{option.text}}</option>
  </select>  
</form>
</template>

<script>
import ebus from 'libs/ebus.js'

export default {
  props: {
    language: {
      type: String,
      required: true
    }
  },
  data () {
    return {
      lanOptions: [{
        value: 'cn',
        text: '简体中文'
      }, {
        value: 'en',
        text: 'English'
      }]
    }
  },
  methods: {
    onChange () {
      ebus.emit('change-language', this.language)
    }
  }
}
</script>

<style scoped>
.form-language {
  position: fixed;
  left: 90%;
  top: 5%;
}
</style>